import socket,json
import time
from multiprocessing import Process
import logging

# 目标地址
TARGET_HOST = 'localhost'
TARGET_PORT = 5555
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
    sock.connect((TARGET_HOST, TARGET_PORT))
    #10表示添加topic 后面跟着的是转为bytes的json数据
    message = bytes([10])+json.dumps({"topic":"test/#","info":{"id":(1,2,3),"data":{}}}).encode('utf-8')
   
    sock.sendall(message)
    response = sock.recv(1024)
    print(response)